package cn.lin.web.servlet;

import cn.lin.service.UserService;
import cn.lin.serviceImpl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delSelectedServlet")
public class DelSelectedServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取所有的id
        String[] uids = req.getParameterValues("uid");
        UserService service = new UserServiceImpl();
        service.delSelectedUser(uids);

        //跳转回主页
        resp.sendRedirect(req.getContextPath() + "/userListServlet");
    }
}
